﻿using Microsoft.AspNetCore.Mvc;
using Zhp.Api.Attributes;
using Zhp.Auth;
using Zhp.IService.Common;
using Zhp.Model.Common;

namespace Zhp.Api.Controllers.Common
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [ApiGroup(GroupName = ApiGroupEnum.Common)]
    public class CommonController : ControllerBase
    {
        protected readonly ICommonService Common;

        public CommonController(ICommonService Common)
        {
            this.Common = Common;
        }

        /// <summary>
        /// 通用查询枚举数据
        /// </summary>
        /// <param name="enumType"></param>
        /// <returns></returns>
        [AllowOnline]
        [HttpGet("{enumType}")]
        public async Task<List<EnumModel>> GetEnumList(string enumType)
        {
            return await Common.GetEnumList(enumType);
        }

        /// <summary>
        /// 查询生成主键
        /// </summary>
        /// <returns></returns>
        [AllowOnline]
        [HttpGet()]
        [HttpGet("{num}")]
        public async Task<BaseRet> GetLongId(int? num)
        {
            return new BaseRet
            {
                DataExt = await Common.GetLongId(num)
            };
        }
    }
}
